package day_2023_7_to_10;

/**
 * @author haomin
 * @date 2023/07/22 16:55
 **/
public class Day_7_21 {
    class Solution {
        public int[] exchange(int[] nums) {
            int l = 0, r = nums.length - 1;
            while(l < r) {
                while(l < r && nums[l] % 2 == 1) l++;
                while(l < r && nums[r] % 2 == 0) r--;
                if (l < r)
                    swip(nums, l , r);
            }
            return nums;
        }
        public void swip(int[] nums, int l , int r) {
            int temp = nums[l];
            nums[l] = nums[r];
            nums[r] = temp;
        }
    }
}